#include <iostream>
#include <vector>
using namespace std;

bool verify(string id);

int main()
{
    int n;
    cin >> n;
    vector<string>ids;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if (!verify(s))
            ids.push_back(s);
    }
    if (ids.empty())
        cout << "All passed";
    else
    {
        for (int i = 0; i < ids.size(); i++)
        {
            cout << ids[i] << endl;
        }
    }

}

bool verify(string id)
{
    int qz[17]{ 7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2 };
    char xym[11]{ '1','0','X','9','8','7','6','5','4','3','2' };
    int sum = 0;
    for (int i = 0; i < 17; i++)
        sum += qz[i] * (id[i] - '0');
    sum = sum % 11;
    if (xym[sum] == id[17])
        return true;
    else
        return false;
}